********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************

****
** Panel data analyses
****

set more off

* SET WORKING DIRECTORY

********************************************************************************

****
** Clean/recode variables
****

use "anes_mergedfile_1992to1997.dta"

* Case ID
gen id92 = VID92 
gen id94 = VID94 
gen id96 = VID96

keep if id92 != . & id96 != .


* Weight
gen weight92 = V923009
gen weight94 = V940005 
gen weight96 = V960004


* Party identification
gen pid92 = V923634 - 3
replace pid92 = . if pid92 > 3
gen pid94 = V940655 - 3
replace pid94 = . if pid94 > 3
gen pid96 = V960420 - 3
replace pid96 = . if pid96 > 3

gen rep92 = 1 if pid92 > 1
replace rep92 = 0 if pid92 < -1
gen rep94 = 1 if pid94 > 1
replace rep94 = 0 if pid94 < -1
gen rep96 = 1 if pid96 > 1
replace rep96 = 0 if pid96 < -1


* Party ID strength
gen pidstrength92 = 3 if abs(pid92) == 3
replace pidstrength92 = 2 if abs(pid92) == 2
replace pidstrength92 = 1 if abs(pid92) == 1
replace pidstrength92 = 0 if abs(pid92) == 0

gen pidstrength94 = 3 if abs(pid94) == 3
replace pidstrength94 = 2 if abs(pid94) == 2
replace pidstrength94 = 1 if abs(pid94) == 1
replace pidstrength94 = 0 if abs(pid94) == 0

gen pidstrength96 = 3 if abs(pid96) == 3
replace pidstrength96 = 2 if abs(pid96) == 2
replace pidstrength96 = 1 if abs(pid96) == 1
replace pidstrength96 = 0 if abs(pid96) == 0


* Ideology
gen ideo92 = V923509 - 4
replace ideo92 = . if abs(ideo92) > 3 
gen ideo94 = V940839 - 4
replace ideo94 = . if abs(ideo94) > 3 
gen ideo96 = V960365 - 4
replace ideo96 = . if abs(ideo96) > 3 

gen conserv92 = 1 if ideo92 > 0
replace conserv92 = 0 if ideo92 < 0
gen conserv94 = 1 if ideo94 > 0
replace conserv94 = 0 if ideo94 < 0
gen conserv96 = 1 if ideo96 > 0
replace conserv96 = 0 if ideo96 < 0


* Ideological strength
gen ideostrength92 = 3 if abs(ideo92) == 3
replace ideostrength92 = 2 if abs(ideo92) == 2
replace ideostrength92 = 1 if abs(ideo92) == 1
replace ideostrength92 = 0 if abs(ideo92) == 0

gen ideostrength94 = 3 if abs(ideo94) == 3
replace ideostrength94 = 2 if abs(ideo94) == 2
replace ideostrength94 = 1 if abs(ideo94) == 1
replace ideostrength94 = 0 if abs(ideo94) == 0

gen ideostrength96 = 3 if abs(ideo96) == 3
replace ideostrength96 = 2 if abs(ideo96) == 2
replace ideostrength96 = 1 if abs(ideo96) == 1
replace ideostrength96 = 0 if abs(ideo96) == 0


* Sorting
replace ideostrength92 = ideostrength92 + 1
replace pidstrength92 = pidstrength92 + 1
gen sorting92 = abs(pid92 - (-1 * ideo92)) * ideostrength92 * pidstrength92

replace ideostrength94 = ideostrength94 + 1
replace pidstrength94 = pidstrength94 + 1
gen sorting94 = abs(pid94 - (-1 * ideo94)) * ideostrength94 * pidstrength94

replace ideostrength96 = ideostrength96 + 1
replace pidstrength96 = pidstrength96 + 1
gen sorting96 = abs(pid96 - (-1 * ideo96)) * ideostrength96 * pidstrength96


* Education (ranges from 1-7)
gen edu92 = V923908
replace edu92 = . if edu92 >= 8
replace edu92 = . if edu92 < 1
label define edulab 1 "8 grades or less" 2 "9-12 grades" 3 "High school" ///
	4 "HS + non-academic training" 5 "Some college" 6 "BA" 7 "Advanced"
label values edu edulab


* Family income (1-24)
gen income92 = V924104
replace income92 = . if income > 24


* Race 
gen race92 = V924202
replace race92 = . if race92 == 9

gen white92 = 0
replace white92 = 1 if race92 == 1

gen black92 = 0
replace black92 = 1 if race92 == 2


* Gender (1=female)
gen female92 = V924201 - 1
replace female92 = . if female92 < 0
replace female92 = . if female92 > 1
label define genderlab 0 "Male" 1 "Female"
label values female92 genderlab


* Age (number of years) 
gen age92 = V923903
replace age92 = . if age92 > 91
replace age92 = . if age92 < 17


* Region
gen south92 = .
replace south92 = 0 
replace south92 = 1 if V923014 == 3
label define southern 0 "0 Non-South" 1 "1 South"
label values south southern


* Church attendance
gen church92 = V923821
replace church92 = . if church92 < 1
recode church92 (5=0) (4=1) (3=2) (2=3) (1=4)


* Interest in campaigns 
gen interest92 = V925102
replace interest92 = . if interest92 > 5
replace interest92 = . if interest92 < 1
recode interest92 (1=3) (3=2) (5=1)
label define interestlab 1 "Not much interested" ///
	2 "Somewhat interested" 3 "Very much interested"
label values interest interestlab


* Interviewer information assessment
gen info92 = V924205
replace info92 = . if info92 > 9
recode info92 (5=0) (4=1) (3=2) (2=3) (1=4)


* Party feeling thermometers
gen reptherm92 = V923318
replace reptherm92 = . if reptherm92 > 100
gen demtherm92 = V923317
replace demtherm92 = . if demtherm92 > 100
gen partydifftherm92 = abs(demtherm92 - reptherm92)

gen reptherm94 = V940302
replace reptherm94 = . if reptherm94 > 100
gen demtherm94 = V940301
replace demtherm94 = . if demtherm94 > 100
gen partydifftherm94 = abs(demtherm94 - reptherm94)

gen reptherm96 = V960293
replace reptherm96 = . if reptherm96 > 100
gen demtherm96 = V960292
replace demtherm96 = . if demtherm96 > 100
gen partydifftherm96 = abs(demtherm96 - reptherm96)


* Candidate feeling thermometers
gen rcandtherm92 = V923305
replace rcandtherm92 = . if rcandtherm92 > 100
gen dcandtherm92 = V923306
replace dcandtherm92 = . if dcandtherm92 > 100
gen diffcandtherm92 = abs(dcandtherm92 - rcandtherm92)

gen rcandtherm96 = V960273
replace rcandtherm96 = . if rcandtherm96 > 100
gen dcandtherm96 = V960272
replace dcandtherm96 = . if dcandtherm96 > 100
gen diffcandtherm96 = abs(dcandtherm96 - rcandtherm96)


* Ideological group feeling thermometers
gen contherm92 = V925319
replace contherm92 = . if contherm92 > 100
gen libtherm92 = V925326
replace libtherm92 = . if libtherm92 > 100
gen diffideotherm92 = abs(libtherm92 - contherm92)

gen contherm94 = V940306
replace contherm94 = . if contherm94 > 100
gen libtherm94 = V940311
replace libtherm94 = . if libtherm94 > 100
gen diffideotherm94 = abs(libtherm94 - contherm94)

gen contherm96 = V961031
replace contherm96 = . if contherm96 > 100
gen libtherm96 = V961032
replace libtherm96 = . if libtherm96 > 100
gen diffideotherm96 = abs(libtherm96 - contherm96)


* Affective polarization
alpha diffideotherm92 diffcandtherm92 partydifftherm92, gen(affectpol92)

alpha diffideotherm96 diffcandtherm96 partydifftherm96, gen(affectpol96)


* Government spending and services
gen selfservice92 = V923701
replace selfservice92 = . if selfservice92 < 1
replace selfservice92 = . if selfservice92 >= 8
recode selfservice92 (1=3) (2=2) (3=1) (4=0) (5=-1) (6=-2) (7=-3)
label define servicelab -3 "Government should provide many more services" ///
	3 "Government should provide many ewer services"
label values selfservice92 servicelab

gen repservice92 = V923702
replace repservice92 = . if repservice92 < 1
replace repservice92 = . if repservice92 >= 8
recode repservice92 (1=3) (2=2) (3=1) (4=0) (5=-1) (6=-2) (7=-3)

gen demservice92 = V923703
replace demservice92 = . if demservice92 < 1
replace demservice92 = . if demservice92 >= 8
recode demservice92 (1=3) (2=2) (3=1) (4=0) (5=-1) (6=-2) (7=-3)

gen pdiffservice92 = abs(repservice92 - demservice92)


gen selfservice96 = V960450
replace selfservice96 = . if selfservice96 < 1
replace selfservice96 = . if selfservice96 >= 8
recode selfservice96 (1=3) (2=2) (3=1) (4=0) (5=-1) (6=-2) (7=-3)

gen repservice96 = V960455
replace repservice96 = . if repservice96 < 1
replace repservice96 = . if repservice96 >= 8
recode repservice96 (1=3) (2=2) (3=1) (4=0) (5=-1) (6=-2) (7=-3)

gen demservice96 = V960453
replace demservice96 = . if demservice96 < 1
replace demservice96 = . if demservice96 >= 8
recode demservice96 (1=3) (2=2) (3=1) (4=0) (5=-1) (6=-2) (7=-3)

gen pdiffservice96 = abs(repservice96 - demservice96)


* Defense spending
gen selfdefense92 = V923707
replace selfdefense92 = . if selfdefense92 < 1
replace selfdefense92 = . if selfdefense92 >= 8
recode selfdefense92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)
label define defenselab -3 "Greatly decrease defense spending" ///
	3 "Greatly increase defense spending"
label values selfdefense92 defenselab

gen repdefense92 = V923708
replace repdefense92 = . if repdefense92 < 1
replace repdefense92 = . if repdefense92 >= 8
recode repdefense92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen demdefense92 = V923709
replace demdefense92 = . if demdefense92 < 1
replace demdefense92 = . if demdefense92 >= 8
recode demdefense92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen pdiffdefense92 = abs(repdefense92 - demdefense92)


gen selfdefense96 = V960463
replace selfdefense96 = . if selfdefense96 < 1
replace selfdefense96 = . if selfdefense96 >= 8
recode selfdefense96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen repdefense96 = V960469
replace repdefense96 = . if repdefense96 < 1
replace repdefense96 = . if repdefense96 >= 8
recode repdefense96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen demdefense96 = V960466
replace demdefense96 = . if demdefense96 < 1
replace demdefense96 = . if demdefense96 >= 8
recode demdefense96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen pdiffdefense96 = abs(repdefense96 - demdefense96)


* Health insurance
gen selfinsure92 = V923716
replace selfinsure92 = . if selfinsure92 < 1
replace selfinsure92 = . if selfinsure92 > 7
recode selfinsure92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)
label define insurelab -3 "Government insurance plan" 3 "Private insurance plan"
label values selfinsure92 insurelab


gen selfinsure96 = V960479
replace selfinsure96 = . if selfinsure96 < 1
replace selfinsure96 = . if selfinsure96 > 7
recode selfinsure96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen repinsure96 = V960481
replace repinsure96 = . if repinsure96 < 1
replace repinsure96 = . if repinsure96 > 7
recode repinsure96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen deminsure96 = V960480
replace deminsure96 = . if deminsure96 < 1
replace deminsure96 = . if deminsure96 > 7
recode deminsure96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen pdiffinsure96 = abs(repinsure96 - deminsure96)


* Guarenteed jobs
gen selfjobs92 = V923718
replace selfjobs92 = . if selfjobs92 < 1
replace selfjobs92 = . if selfjobs92 >= 8
recode selfjobs92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)
label define jobslab -3 "Government see to job and good standard of living" ///
	3 "Government let each person get ahead on his own"
label values selfjobs92 jobslab

gen repjobs92 = V923719
replace repjobs92 = . if repjobs92 < 1
replace repjobs92 = . if repjobs92 >= 8
recode repjobs92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen demjobs92 = V923720
replace demjobs92 = . if demjobs92 < 1
replace demjobs92 = . if demjobs92 >= 8
recode demjobs92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen pdiffjobs92 = abs(repjobs92 - demjobs92)


gen selfjobs96 = V960483
replace selfjobs96 = . if selfjobs96 < 1
replace selfjobs96 = . if selfjobs96 >= 8
recode selfjobs96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen repjobs96 = V960485
replace repjobs96 = . if repjobs96 < 1
replace repjobs96 = . if repjobs96 >= 8
recode repjobs96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen demjobs96 = V960484
replace demjobs96 = . if demjobs96 < 1
replace demjobs96 = . if demjobs96 >= 8
recode demjobs96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen pdiffjobs96 = abs(repjobs96 - demjobs96)


* Aid to blacks
gen selfaid92 = V923724
replace selfaid92 = . if selfaid92 == 0
replace selfaid92 = . if selfaid92 >= 8
recode selfaid92 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)
label define aidlab -3 "Government should help minority groups" ///
	3 "Minority groups should help themselves"
label values selfaid92 aidlab


gen selfaid96 = V960487
replace selfaid96 = . if selfaid96 == 0
replace selfaid96 = . if selfaid96 >= 8
recode selfaid96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen repaid96 = V960492
replace repaid96 = . if repaid96 == 0
replace repaid96 = . if repaid96 >= 8
recode repaid96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen demaid96 = V960490
replace demaid96 = . if demaid96 == 0
replace demaid96 = . if demaid96 >= 8
recode demaid96 (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen pdiffaid96 = abs(repaid96 - demaid96)


* Perceived polarization
alpha pdiffservice92 pdiffdefense92 pdiffjobs92, gen(ppol92)

alpha pdiffaid96 pdiffjobs96 pdiffinsure96 pdiffdefense96 ///
	pdiffservice96, gen(ppol96) 

* Issue extremity
gen issex1 = abs(selfdefense92 - 0)
gen issex2 = abs(selfservice92 - 0)	
gen issex3 = abs(selfaid92 - 0)	
gen issex4 = abs(selfinsure92 - 0)	
gen issex5 = abs(selfjobs92 - 0)	
	
alpha issex1-issex5, gen(issextreme92)


* Do whatever is necessary for equal opportunity
* Note: This variable is reverse coded so that higher values indicate
* more conservative attitudes
gen equalopp92 = V926024 - 1
gen equalopp94 = V940914 - 1
gen equalopp96 = V961229 - 1

replace equalopp92 = . if equalopp92 > 4
replace equalopp94 = . if equalopp94 > 4
replace equalopp96 = . if equalopp96 > 4

label define equalopportunity 0 "0 Agree strongly" 1 "1 Agree somewhat" ///
	2 "2 Neither agree nor disagree" 3 "3 Disagree somewhat" ///
	4 "4 Disagree strongly"
label values equalopp92 equalopportunity
label values equalopp94 equalopportunity
label values equalopp96 equalopportunity


* Have gone too far pushing equal rights
* Note: This variable is reverse coded so that higher values indicate
* more conservative attitudes
gen equalrights92 = V926025
gen equalrights94 = V940915
gen equalrights96 = V961230

replace equalrights92 = . if equalrights92 > 5
recode equalrights92 (5=0) (4=1) (3=2) (2=3) (1=4)
replace equalrights94 = . if equalrights94 > 5
recode equalrights94 (5=0) (4=1) (3=2) (2=3) (1=4)
replace equalrights96 = . if equalrights96 > 5
recode equalrights96 (5=0) (4=1) (3=2) (2=3) (1=4)

label define equalrightspush 0 "0 Disagree strongly" 1 "1 Disagree somewhat" /// 
	2 "2 Neither agree nor disagree" 3 "3 Agree somewhat" 4 "4 Agree strongly"
label values equalrights92 equalrightspush
label values equalrights94 equalrightspush
label values equalrights96 equalrightspush


* Big problem is not giving everyone an equal chance*
gen equalchance92 = V926029 - 1
gen equalchance94 = V940916 - 1
gen equalchance96 = V961231 - 1

replace equalchance92 = . if equalchance92 > 4
replace equalchance94 = . if equalchance94 > 4
replace equalchance96 = . if equalchance96 > 4

label define equalchances 0 "0 Agree strongly" 1 "1 Agree somewhat" ///
	2 "2 Neither agree nor disagree" 3 "3 Disagree somewhat" ///
	4 "4 Disagree strongly"
label values equalchance92 equalchances
label values equalchance94 equalchances
label values equalchance96 equalchances


* Better off if we worried less about equality
* Note: This variable is reverse coded so that higher values indicate
* more conservative attitudes
gen lessequal92 = V926026
gen lessequal94 = V940917
gen lessequal96 = V961232

replace lessequal92 = . if lessequal92 > 5
recode lessequal92 (5=0) (4=1) (3=2) (2=3) (1=4)
replace lessequal94 = . if lessequal94 > 5
recode lessequal94 (5=0) (4=1) (3=2) (2=3) (1=4)
replace lessequal96 = . if lessequal96 > 5
recode lessequal96 (5=0) (4=1) (3=2) (2=3) (1=4)

label define lessequality 0 "0 Disagree strongly" 1 "1 Disagree somewhat" /// 
	2 "2 Neither agree nor disagree" 3 "3 Agree somewhat" 4 "4 Agree strongly"
label values lessequal92 lessequality
label values lessequal94 lessequality
label values lessequal96 lessequality


* Not that big of a problem if people have more of a chance
* Note: This variable is reverse coded so that higher values indicate
* more conservative attitudes ???????
gen unequal92 = V926027
gen unequal94 = V940918
gen unequal96 = V961233

replace unequal92 = . if unequal92 > 5
recode unequal92 (5=0) (4=1) (3=2) (2=3) (1=4)
replace unequal94 = . if unequal94 > 5
recode unequal94 (5=0) (4=1) (3=2) (2=3) (1=4)
replace unequal96 = . if unequal96 > 5
recode unequal96 (5=0) (4=1) (3=2) (2=3) (1=4)

label define unequalchance 0 "0 Disagree strongly" 1 "1 Disagree somewhat" ///
	2 "2 Neither agree nor disagree" 3 "3 Agree somewhat" 4 "4 Agree strongly"
label values unequal92 unequalchance
label values unequal94 unequalchance
label values unequal96 unequalchance


* Many fewer problems if people were treated equally
gen fewer92 = V926028 - 1
gen fewer94 = V940919 - 1
gen fewer96 = V961234 - 1

replace fewer92 = . if fewer92 > 4
replace fewer94 = . if fewer94 > 4
replace fewer96 = . if fewer96 > 4

label define fewerproblems04 0 "0 Agree strongly" 1 "1 Agree somewhat" ///
	2 "2 Neither agree nor disagree" 3 "3 Disagree somewhat" ///
	4 "4 Disagree strongly"
label values fewer92 fewerproblems04
label values fewer94 fewerproblems04
label values fewer96 fewerproblems04


* Adjusting views of moral behavior
gen changing92 = V926115 - 1
gen changing94 = V941030 - 1
gen changing96 = V961248 - 1

replace changing92 = . if changing92 > 4
replace changing94 = . if changing94 > 4
replace changing96 = . if changing96 > 4

label define changingmorals 0 "Agree strongly" 1 "Agree somewhat" ///
	2 "Neither agree nor disagree" 3 "Disagree somewhat" 4 "Disagree strongly"
label values changing92 changingmorals
label values changing94 changingmorals
label values changing96 changingmorals
 
 
* Newer lifestyles contributing to a breakdown in society
* Note: This variable is reverse coded so that higher values indicate*
* more conservative attitudes
gen lifestyles92 = V926118
gen lifestyles94 = V941029
gen lifestyles96 = V961247

replace lifestyles92 = . if lifestyles92 > 5
recode lifestyles92 (5=0) (4=1) (3=2) (2=3) (1=4)
replace lifestyles94 = . if lifestyles94 > 5
recode lifestyles94 (5=0) (4=1) (3=2) (2=3) (1=4)
replace lifestyles96 = . if lifestyles96 > 5
recode lifestyles96 (5=0) (4=1) (3=2) (2=3) (1=4)


label define lifestylesnew 0 "0 Disagree strongly" 1 "1 Disagree somewhat" /// 
	2 "2 Neither agree nor disagree"  3 "3 Agree somewhat" 4 "4 Agree strongly"
label values lifestyles92 lifestylesnew
label values lifestyles94 lifestylesnew
label values lifestyles96 lifestylesnew


* Tolerant of people who choose to live according to their own moral standards
gen standards92 = V926116 - 1
gen standards94 = V941032 - 1
gen standards96 = V961250 - 1

replace standards92 = . if standards92 > 4
replace standards94 = . if standards94 > 4
replace standards96 = . if standards96 > 4

label define standardsown 0 "0 Agree strongly" 1 "1 Agree somewhat" ///
	2 "2 Neither agree nor disagree" 3 "3 Disagree somewhat" ///
	4 "4 Disagree strongly"
label values standards92 standardsown
label values standards94 standardsown
label values standards96 standardsown
 
 
* More emphasis on traditional family ties*
* Note: This variable is reverse coded so that higher values indicate
* more conservative attitudes
gen family92 = V926117
gen family94 = V941031
gen family96 = V961249

replace family92 = . if family92 > 5
recode family92 (5=0) (4=1) (3=2) (2=3) (1=4)
replace family94 = . if family94 > 5
recode family94 (5=0) (4=1) (3=2) (2=3) (1=4)
replace family96 = . if family96 > 5
recode family96 (5=0) (4=1) (3=2) (2=3) (1=4)


label define familyties 0 "0 Disagree strongly" 1 "1 Disagree somewhat" /// 
	2 "2 Neither agree nor disagree"  3 "3 Agree somewhat" 4 "4 Agree strongly"
label values family92 familyties
label values family94 familyties
label values family96 familyties


* Creating values scales
alpha equalopp92 equalrights92 equalchance92 lessequal92 unequal92 fewer92 ///
	changing92 lifestyles92 standards92 family92, detail item ///
	generate(valuescale92) 

alpha equalopp94 equalrights94 equalchance94 lessequal94 unequal94 fewer94 ///
	changing94 lifestyles94 standards94 family94, detail item ///
	generate(valuescale94) 

alpha equalopp96 equalrights96 equalchance96 lessequal96 unequal96 fewer96 ///
	changing96 lifestyles96 standards96 family96, detail item ///
	generate(valuescale96) 
	
	
* Value polarization	
gen valuepold92 = .
gen valuepolr92 = .	
gen valuepold94 = .
gen valuepolr94 = .	
gen valuepold96 = .
gen valuepolr96 = .	
	
sum valuescale92 if valuescale92 != . & rep92 == 1, meanonly
replace valuepold92 = valuescale92 - r(mean) if valuescale92 != . & rep92 == 0
sum valuescale92 if valuescale92 != . & rep92 == 0, meanonly
replace valuepolr92 = valuescale92 - r(mean) if valuescale92 != . & rep92 == 1

sum valuescale94 if valuescale94 != . & rep94 == 1, meanonly
replace valuepold94 = valuescale94 - r(mean) if valuescale94 != . & rep94 == 0
sum valuescale94 if valuescale94 != . & rep94 == 0, meanonly
replace valuepolr94 = valuescale94 - r(mean) if valuescale94 != . & rep94 == 1

sum valuescale96 if valuescale96 != . & rep96 == 1, meanonly
replace valuepold96 = valuescale96 - r(mean) if valuescale96 != . & rep96 == 0
sum valuescale96 if valuescale96 != . & rep96 == 0, meanonly
replace valuepolr96 = valuescale96 - r(mean) if valuescale96 != . & rep96 == 1

foreach v of var valuepold92 - valuepolr96{ 
	replace `v' = abs(`v')
}

egen valuepol92 = rowtotal(valuepold92 valuepolr92)
egen valuepol94 = rowtotal(valuepold94 valuepolr94)
egen valuepol96 = rowtotal(valuepold96 valuepolr96)

********************************************************************************

****
** Table 2
****

* Model 1
sem (valuepol96 <- valuepol92 partydifftherm92 sorting92 issextreme92 ///
	interest92 edu92 age92 income92 church92 female92 white92 black92 south92) ///
	(partydifftherm96 <- valuepol92 partydifftherm92 sorting92 issextreme92 ///
	interest92 edu92 age92 income92 church92 female92 white92 black92 south92), ///
	standardized method(mlmv) 
estat gof, stats(all)	

* Model 2
sem (valuepol96 <- valuepol92 diffideotherm92 sorting92 issextreme92 ///
	interest92 edu92 age92 income92 church92 female92 white92 black92 south92) ///
	(diffideotherm96 <- valuepol92 diffideotherm92 sorting92 issextreme92 ///
	interest92 edu92 age92 income92 church92 female92 white92 black92 south92), ///
	standardized method(mlmv)
estat gof, stats(all)	

* Model 3
sem (valuepol96 <- valuepol92 diffcandtherm92 sorting92 issextreme92 ///
	interest92 edu92 age92 income92 church92 female92 white92 black92 south92) ///
	(diffcandtherm96 <- valuepol92 diffcandtherm92 sorting92 issextreme92 ///
	interest92 edu92 age92 income92 church92 female92 white92 black92 south92), ///
	standardized method(mlmv) 
estat gof, stats(all)
